<?php

class Soul_Request_Result_Template extends Soul_Request_Result_Base {
	
	private $_file = '';
	
	public function getFile(){
		return $this->_file;
	}
	
	public function setFile($value){
		$this->_file = $value;
		return $this;
	}

    public function execute() {
    	$tmpl = new Soul_Template_Template();
    	Soul_Template_Context::getInstance()->addData($this->getAllData());
    	$tmplPath = $this->getFile();
    	if(strpos($tmplPath, '.') === FALSE){
    		$tmplPath .= '.phtml';
    	}
    	if(!file_exists($tmplPath)){
    		$tmplPath = Soul_Util_FS::findFile($this->getContext()->getTemplateDirectories(), $tmplPath);
    	}
    	$this->getContext()->getResponse()->write($tmpl->render($tmplPath));
    }
}